package bishi.day16_5_12;

import java.util.Scanner;

/**
 * @author 是阿秋啊
 * @date 2022/05/12 20:43
 **/
public class Perfect_number {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int count = 0;
            for (int i = 2; i <= n; i++) {
                if(isPerfect(i)) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
    public static boolean isPerfect(int n) {
        int sum = 0;
        for(int i = 1; i*i <= n; i++) {
            if(n % i == 0) {
                sum += i;
                if(n / i != i && i != 1) {
                    sum += n / i;
                }
            }
        }
        return sum == n;
    }
}